require('dotenv').config()
const { notarize } = require('@electron/notarize')

exports.default = async function packageTask(context) {
  const appName = context.packager.appInfo.productFilename
  const { electronPlatformName, appOutDir } = context
  if (electronPlatformName !== 'darwin') {
    return
  }

  let appPath = `${appOutDir}/${appName}.app`
  let { appleId, appleIdPassword, teamId } = process.env
  console.log("notarize")
  console.dir({ appleId, appleIdPassword, teamId })
  return await notarize({
    appPath,
    appleId,
    appleIdPassword,
    teamId,
  })
}